package consul

type ServiceRegister struct {
	consulClient  *Client
	serviceConfig *ServiceConfig
}

func NewRegister(address string, serviceConfig *ServiceConfig) *ServiceRegister {
	return &ServiceRegister{
		consulClient:  NewConsulClient(address),
		serviceConfig: serviceConfig,
	}
}

func (r *ServiceRegister) Register() error {
	return r.consulClient.RegisterService(r.serviceConfig)
}
func (r *ServiceRegister) Deregister() error {
	return r.consulClient.DeregisterService(r.serviceConfig.ID)
}
